package com.wolfpire.workflow.cmd;

import org.hibernate.Session;
import org.jbpm.api.cmd.Environment;
import org.jbpm.pvm.internal.cmd.AbstractCommand;
import org.jbpm.pvm.internal.task.ParticipationImpl;

/**
 * 更新单条参与者记录
 * @author zhenghuazhen
 *
 */
public class UpdateParticipationCmd extends AbstractCommand<ParticipationImpl> {

	private static final long serialVersionUID = 4037344522275350417L;
	
	protected ParticipationImpl participation;

    public UpdateParticipationCmd (ParticipationImpl participation ) {
        this.participation = participation;
    }
    
	public ParticipationImpl execute(Environment environment) throws Exception {
		Session session = environment.get(Session.class);				
		if (null != participation) {
			session.update(participation);			
			return (ParticipationImpl)session.get(ParticipationImpl.class, participation.getDbid());
		}		
		return null;		
	}

}
